package immutablecollections;

import java.util.*;

/**
 * An iterator on an {@link ImRoseTree}.
 * 
 * Because `ImRoseTrees` are immutable, {@link #remove} will throw {@link UnsupportedOperationException}
 * 
 * @see ImRoseTree
 * @see ImRoseTreeZipper
 * @see ImRoseTreeZipperIterator
 *
 */
public class ImRoseTreeIterator<T> implements Iterator<T>
{

    private Iterator<ImRoseTreeZipper<T>> zipperIterator;

    public ImRoseTreeIterator(final ImRoseTree<T> tree)
    {
        zipperIterator = tree.getZipperIterator();
    }

    public boolean hasNext()
    {
        return zipperIterator.hasNext();
    }

    public T next()
    {
        return zipperIterator.next().getElement();
    }

    public void remove()
    {
        throw new UnsupportedOperationException();
    }
}
